package com.tjcu.service.impl;

import com.tjcu.dao.CityDao;
import com.tjcu.entity.City;
import com.tjcu.service.CityService;
import com.tjcu.utils.MybatisUtil;

import java.util.List;

/**
 * @author 王恒杰
 * @version 1.0
 * @date 2021/11/1 17:02
 * @email 1078993387@qq.com
 * @Address 天津
 * @Description:
 */
public class CityServiceImpl implements CityService {
    @Override
    public void insertCity(City city) {
        CityDao mapper = (CityDao) MybatisUtil.getMapper(CityDao.class);
        mapper.insertCity(city);
        MybatisUtil.commit();
    }

    @Override
    public void deleteCity(Integer id) {
        CityDao mapper = (CityDao) MybatisUtil.getMapper(CityDao.class);
        mapper.deleteCity(id);
        MybatisUtil.commit();
    }

    @Override
    public List<City> selectCity() {
        CityDao mapper = (CityDao) MybatisUtil.getMapper(CityDao.class);
        List<City> cities = mapper.selectCity();
        MybatisUtil.close();
        return cities;
    }
}
